#include<bits/stdc++.h>
using namespace std;
int n,L,R;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&L,&R);
	register int r=R,l=max(L,R-R%n-1);
	printf("%d\n",max(r%n,l%n));
	return 0;
} //henghenghengaaaaaaaaaaaaaaa
